<?php

 Zend_Loader::loadClass("BaseControllerAuth");
 class NfaController extends BaseControllerAuth
 {
 	public function initialize()
 	{
		Zend_Loader::loadClass("UserTypes");
		Zend_Loader::loadClass("CodesUtility");
	
		$auth = BaseAuth::getInstance();
		
		$this->setLayout("account");
		$this->assign("pageTitle","Trade Management System - PNG National Fisheries Authority" . $this->getConfig()->client->name);
		$userTypes = new UserTypes();
		$userTypesArray = $userTypes->getUserTypesArray("code", "id");

		
		$this->assign("viewType",$userTypesArray[CodesUtility::USER_TYPE_NFA]);
		if($userTypesArray[CodesUtility::USER_TYPE_NFA] != $auth->user_type_id) {
			$this->deAuthenticate();
		}
		$this->assign("controller","nfa");
 	}
	
	
	public function deAuthenticate()
 	{
		$auth = BaseAuth::getInstance();
		$auth->deAuthenticate();
 	}
	
	public function indexAction() {
	
		Zend_Loader::loadClass("CartUtility");
		Zend_Loader::loadClass("AuthUtility");
		Zend_Loader::loadClass("MenuUtility");
		Zend_Loader::loadClass("Organization");
		
		Zend_loader::loadClass("AccountUtility");
		$acctUtility = new AccountUtility();
		
		$data = $acctUtility->getDashboard(CodesUtility::USER_TYPE_NFA);
		
		
		$auth = BaseAuth::getInstance();
  		$this->assign("username",$auth->username);
		$organization = new Organization();
		$organization->loadWhere(" org_id = ". $auth->org_id);
		
		$menuUtility = new MenuUtility();
		
		$this->assign("data",$data);
		$this->assign("pageTitle","Trade Management System - PNG National Fisheries Authority". $organization->name );
		$this->assign("menuUtility" ,$menuUtility);

		$this->render("home.tpl");		
	}
	
	public function homeAction(){
		Zend_Loader::loadClass("AccountUtility");
		Zend_Loader::loadClass("CodesUtility");
		
		$acctUtility = new AccountUtility();
		
		$data = $acctUtility->getDashboard(CodesUtility::USER_TYPE_NFA);
	
		$this->setNoLayout();
		$this->assign("data",$data);
		$this->render("home.tpl");
	}	
 }
?>